//
//  WCNotifyMessageCell.m
//  WC
//
//  Created by wsj2015 on 16/1/21.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNotifyMessageCell.h"
#import "WCImageView +setImage.h"
#import "NSString+Utilities.h"

@implementation WCNotifyMessageCell

- (void)awakeFromNib {
    // Initialization code
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.cornerRadius =5;
//    self.backgroundColor = kAppBg;
    self.tagView.layer.masksToBounds =YES;
    self.tagView.layer.cornerRadius =3;
    
    self.notiCycle.layer.borderWidth =1;
    self.notiCycle.layer.borderColor = [UIColor whiteColor].CGColor;
    self.notiCycle.layer.masksToBounds = YES;
    self.notiCycle.layer.cornerRadius =6;
    self.tagView.hidden = YES;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (instancetype)cellForTableView:(UITableView*)tableView indexPath:(NSIndexPath *)indexPath
{
    static NSString *cellId =@"notifyMessageCellId";
    WCNotifyMessageCell *cell =[tableView dequeueReusableCellWithIdentifier:cellId forIndexPath:indexPath];
   
    return cell;

}
- (void)setModel:(id )model{
    _model = model;
     self.iconView.image = [UIImage imageNamed:@"图片占位"];
    if ([model isKindOfClass:[WCNotifyMessageModel class]]) {
        WCNotifyMessageModel *noti =model;
       
        NSString *imageName;
        if ([noti.messageType integerValue]==1) {
            imageName = @"订单提醒";
        }else if ([noti.messageType integerValue]==10) {
            imageName = @"留言提醒";
        }else  {
            imageName = @"站内提醒";
        }
        self.iconView.image =[UIImage imageNamed:imageName];
        
        self.titleLab.text = noti.messageTitle;
        self.desLabel.text = noti.messageContent;
        self.timeLabel.text = [NSString timeStringYYMMDDFrom:[noti.addDate longLongValue]];
        self.notiCycle.hidden =[noti.messageStatus integerValue]==1?NO:YES;
        self.titleLab.textColor =[UIColor blackColor];
    }else{
        WSJConversion *conversion = model;
        self.titleLab.text = @"在线咨询";
        self.titleLab.textColor =[UIColor redColor];
//        if (conversion.detailText.length>10) {
//            
//             self.desLabel.text =[NSString stringWithFormat:@"%@(来自%@)",[conversion.detailText substringWithRange:NSMakeRange(0, 9)],conversion.patientName];
//        }
        
        self.desLabel.text =[NSString stringWithFormat:@"%@(来自%@)", conversion.detailText,conversion.patientName];
    
    }
    
   

    
    

}
@end
